clear all
set more off
capture log close
pause on

* This .do file starts with the file attachment sent on June 28 2021.  SC altered the top row manually to create some variable names in the .csv

/* SC */ cd "/Users/robertchaudoin/Dropbox/Complementarity ZC/Survey_ZA/ZAF data/"
/* KZ */ capture use "/Users/kelebogilezvobgo/Dropbox/Complementarity/", clear

import delimited using "21012502 Havard SA 12072021 All varnames.csv", clear


capture rename ïstatus status
drop if status != "Complete"

* QQQ is an internal marker for practice runs of the survey; not an actual respondent if their ID contains "QQQ"
drop if strpos(sguidrmsid, "QQQ")

*** Treatment indicator
gen treatment = 0
replace treatment = 1 if strpos(recap, "can only")

*** Outcome measures variable construction
* The "_nn" versions stand for "no neither agree/disagree answers."  Those respondents are coded as missing for this version.

* Support for an ICC investigation
gen iccsupport_bin = 0
replace iccsupport_bin = 1 if iccinvsupport == "Somewhat agree" | iccinvsupport == "Strongly agree"

gen iccsupport_bin_nn = 0
replace iccsupport_bin_nn = 1 if iccinvsupport == "Somewhat agree" | iccinvsupport == "Strongly agree"
replace iccsupport_bin_nn = . if iccinvsupport == "Neither agree nor disagree"

gen iccsupport_num = .
replace iccsupport_num = 0 if iccinvsupport == "Strongly disagree"
replace iccsupport_num = 1 if iccinvsupport == "Somewhat disagree"
replace iccsupport_num = 2 if iccinvsupport == "Neither agree nor disagree"
replace iccsupport_num = 3 if iccinvsupport == "Somewhat agree"
replace iccsupport_num = 4 if iccinvsupport == "Strongly agree"


* Support for a domestic investigation in the target country
gen countryinvsupport_bin = 0
replace countryinvsupport_bin = 1 if countryinvsupport == "Somewhat agree" | countryinvsupport == "Strongly agree"

gen countryinvsupport_bin_nn = 0
replace countryinvsupport_bin_nn = 1 if countryinvsupport == "Somewhat agree" | countryinvsupport == "Strongly agree"
replace countryinvsupport_bin_nn = . if countryinvsupport == "Neither agree nor disagree"

gen countryinvsupport_num = .
replace countryinvsupport_num = 0 if countryinvsupport == "Strongly disagree"
replace countryinvsupport_num = 1 if countryinvsupport == "Somewhat disagree"
replace countryinvsupport_num = 2 if countryinvsupport == "Neither agree nor disagree"
replace countryinvsupport_num = 3 if countryinvsupport == "Somewhat agree"
replace countryinvsupport_num = 4 if countryinvsupport == "Strongly agree"


* ICC bias
gen iccbiased_bin = 0
replace iccbiased_bin = 1 if iccbiased == "Somewhat agree" | iccbiased == "Strongly agree"

gen iccbiased_bin_nn = 0
replace iccbiased_bin_nn = 1 if iccbiased == "Somewhat agree" | iccbiased == "Strongly agree"
replace iccbiased_bin_nn = . if iccbiased == "Neither agree nor disagree"


gen iccbiased_num = .
replace iccbiased_num = 0 if iccbiased == "Strongly disagree"
replace iccbiased_num = 1 if iccbiased == "Somewhat disagree"
replace iccbiased_num = 2 if iccbiased == "Neither agree nor disagree"
replace iccbiased_num = 3 if iccbiased == "Somewhat agree"
replace iccbiased_num = 4 if iccbiased == "Strongly agree"


* Support for SA helping the ICC
gen sasupporticc_bin = 0
replace sasupporticc_bin = 1 if sasupporticc == "Somewhat agree" | sasupporticc == "Strongly agree"

gen sasupporticc_bin_nn = 0
replace sasupporticc_bin_nn = 1 if sasupporticc == "Somewhat agree" | sasupporticc == "Strongly agree"
replace sasupporticc_bin_nn = . if sasupporticc == "Neither agree nor disagree"

gen sasupporticc_num = .
replace sasupporticc_num = 0 if sasupporticc == "Strongly disagree"
replace sasupporticc_num = 1 if sasupporticc == "Somewhat disagree"
replace sasupporticc_num = 2 if sasupporticc == "Neither agree nor disagree"
replace sasupporticc_num = 3 if sasupporticc == "Somewhat agree"
replace sasupporticc_num = 4 if sasupporticc == "Strongly agree"


*** South African Legal system
gen salegsyscapable_bin = 0
replace salegsyscapable_bin = 1 if salegalsystem == "Somewhat agree" | salegalsystem == "Strongly agree"

gen salegsyscapable_bin_nn = 0
replace salegsyscapable_bin_nn = 1 if salegalsystem == "Somewhat agree" | salegalsystem == "Strongly agree"
replace salegsyscapable_bin_nn = . if salegalsystem == "Neither agree nor disagree"

*** Other countries' legal systems
gen otherlegsyscapable_bin = 0
replace otherlegsyscapable_bin = 1 if otherlegalsystem == "Somewhat agree" | otherlegalsystem == "Strongly agree"

gen otherlegsyscapable_bin_nn = 0
replace otherlegsyscapable_bin_nn = 1 if otherlegalsystem == "Somewhat agree" | otherlegalsystem == "Strongly agree"
replace otherlegsyscapable_bin_nn = . if otherlegalsystem == "Neither agree nor disagree"



***
* Respondent characteristics setup
***

*** Female
gen female = 0
replace female = 1 if gender == "Female"


*** Ethnicity
* Making indicators for the three largest in the sample
foreach eth in English Zulu Xhosa {
	gen `eth' = 0
	replace `eth' = 1 if ethnicity1 == "`eth'"
	}
*

*** Religion
* Making a Christian indicator (77% of the sample)
gen christian = 0
replace christian = 1 if religion1 == "Christian"

*** Language
* 95% took it in English

*** Education
* . table education, stubwidth(40)
*I am post-secondary graduated (e g , voc |      1,070 * I am post-secondary graduated (e g , vocational certuficate, Bachelors degree, Masters degree, Doctorate)
*I attendend post-secondary school but I  |        385
*              I have no formal education |         11
*         I only completed primary school |         11
*       I only completed secondary school |        542
gen education_postsec = 0
replace education_postsec = 1 if  strpos(education, "I am")

*** Income
* Constructed indicators for 0-25th percentiles, 26-75, and 76+
gen income_lower25th = 0
gen income_26thto75th = 0
gen income_above75th = 0

replace income_lower25th = 1 if income <= 8000
replace income_26thto75th = 1 if income > 8000 & income <= 30000
replace income_above75th = 1 if income > 30000

*** Party ID
gen party_anc = 0
replace party_anc = 1 if party1 == "African National Congress"
gen party_da = 0
replace party_da = 1 if party1 == "Democratic Alliance"

*** Newshours
* Median is 5
gen newshours_morethan5 = 0
replace newshours_morethan5 = 1 if newshours > 5

*** Marital status
gen married = 0
replace married = 1 if marital == "Married"

*** Region
* There are 9 regions coded; this is just an indicator for Gauteng (containing Joburg and Pretoria)
gen gauteng = 0
replace gauteng = 1 if region == "Gauteng"




***
* Other variables
***

*** Manipulation check variable construction
* Substrings from correct answers: "That country already"... // "The ICC cannot"...
gen manip1_correct = 0
replace manip1_correct = 1 if strpos(manipcheck1, "That country already")

gen manip2_correct = 0
replace manip2_correct = 1 if strpos(manipcheck2, "The ICC cannot")
 
gen complier1 = 0
gen complier2 = 0
gen complier1and2 = 0

replace complier1 = 1 if treatment == 1 & manip1_correct == 1
replace complier1 = 1 if treatment == 0

replace complier2 = 1 if treatment == 1 & manip2_correct == 1
replace complier2 = 1 if treatment == 0

replace complier1and2 = 1 if treatment == 1 & manip1_correct == 1 & manip2_correct == 1
replace complier1and2 = 1 if treatment == 0
	* In the USA survey, I labelled these "cchec" for "comprehension check."
 
 
 
export delimited using "ZAF_processed_2021_07_12.csv", replace
 
 
 
 
 
***********************
* Analysis in Stata
***********************

/* SC */ cd "/Users/robertchaudoin/Dropbox/Complementarity ZC/Survey_ZA/ZAF data/"
/* KZ */ capture use "/Users/kelebogilezvobgo/Dropbox/Complementarity/", clear


import delimited using "ZAF_processed_2021_07_12.csv", clear


***
* Descriptive stats
***

global ctrls female age education_postsec income_lower25th income_26thto75th income_above75th English Zulu Xhosa christian party_anc party_da newshours_morethan5 gauteng 
global dvs iccsupport_bin countryinvsupport_bin iccbiased_bin sasupporticc_bin

estpost su treatment $dvs $ctrls
	est store full
estpost su treatment $dvs $ctrls if treatment == 1
	est store compl
estpost su treatment $dvs $ctrls if treatment == 0
	est store ctrl

*	Making summary stats table, means only, full - treatment only - control only
	esttab full compl ctrl ///
		using "/Users/robertchaudoin/Dropbox/Complementarity ZC/Survey_ZAF/meanstats_tmtctrl_labelled_zaf.tex", replace ///
		cells(mean(fmt(2))) nodep nonum  ///
		mtitle("Full" "Treatment" "Control") ///
		coeflabels(treatment "Compl. Treatment" ///
		iccsupport_bin "Support ICC Inv." countryinvsupport_bin "Support Local Inv." iccbiased_bin "ICC is biased" sasupporticc_bin "ZAF Support the ICC" ///
		female "Female" age "Age" education_postsec "Post-Sec. Educ." income_lower25th "Income < 25th percentile" income_26thto75th "Income 26-75th percentile" income_above75th "Income > 75th percentile" English "English" Zulu "Zulu" Xhosa "Xhoasa" christian "Christian" party_anc "Party - ANC" party_da "Party - Democratic Alliance" newshours_morethan5 "News hours per week (>5)" gauteng "Gauteng") ///


 
 
***************************************************************************************
*ANALYSIS
***************************************************************************************

global controls "English Zulu Xhosa christian age female income_lower25th income_26thto75th education_postsec newshours_morethan5 gauteng"
* Omitted income_above75th

***
* Outcome measures
***

foreach dv in iccsupport countryinvsupport iccbiased sasupporticc salegsyscapable otherlegsyscapable {
		reg `dv'_bin treatment
		reg `dv'_bin treatment $controls
		reg `dv'_bin_nn treatment
		reg `dv'_bin_nn treatment $controls
		di ".............................."
	}
*


***
* Manipulation checks
***
bysort treatment: tab manip1_correct
bysort treatment: tab manip2_correct

forvalues i = 1(1)2 {
	reg manip`i'_correct treatment
	}
